package cn.itcast.flink.redis;

import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * Author itcast
 * Date 2022/1/21 17:30
 * Desc TODO
 */
public class RedisUtils {
    //jedis 连接 redis 连接池
    private static JedisPool jedisPool;
    private static JedisPoolConfig config;

    /**
     * 获取连接池
     */
    public static JedisPool redisConnectionPool(){
        config = new JedisPoolConfig();
        config.setMaxIdle(10);
        config.setMaxWaitMillis(3000);
        config.setMaxTotal(50);
        config.setMinIdle(5);
        jedisPool = new JedisPool(config, "node3.itcast.cn", 6379);
        return jedisPool;
    }

    public void closePool(){
        jedisPool.close();
    }
}
